<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.css" />
<link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.min.css" />
<script type="text/javascript" src="/static/h-ui/js/jquery-3.6.0.min.js"></script>
<title>新增信息</title>
</head>
<body>
<div class="panel panel-default">
	<div class="panel-header">表单</div>
	<div class="panel-body">
		<div class="row cl">
			<label class="form-label col-xs-3">名字：</label>
				<div class="formControls col-xs-8">
					<input type="text" class="input-text" value=""  name="name" id="name" autocomplete="off">
				</div>
					<div class="col-xs-8 col-xs-offset-3">
					
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3">中文内容：</label>
				<div class="formControls col-xs-8">
					<textarea cols="" rows="" class="textarea" name="content" id="content"  ></textarea>
				</div>
			</div>
			
			<div class="row clearfix">
				<label class="form-label col-xs-3">分类：</label>
				<div class="formControls col-xs-8">
					<div class="row clearfix" style="margin-top:0">
						<div class="col-xs-6">
							<span class="select-box">
								<select class="select" size="1" name="city" id="type">
									<option value="" selected>选择分类</option>
									{volist name='cat_list' id='cat'}
					          			<option  value="{$cat.type_id}">{$cat.type_name}</option>
					          		{/volist}
								</select>
							</span>
						</div>
				
					</div>
				</div>
			</div>
			
			<div class="row clearfix">
				<label class="form-label col-xs-3">二级分类：</label>
				<div class="formControls col-xs-8">
					<div class="row clearfix" style="margin-top:0">
						<div class="col-xs-6">
							<span class="select-box">
								<select class="select" size="1" name="city" id="type2">
									<option value="" selected>选择二级分类</option>

								</select>
							</span>
						</div>
				
					</div>
				</div>
			</div>

			<div class="row cl">
				<div class="col-xs-8 col-xs-offset-3">
					<input type="button" class="btn btn-primary radius" id="submitbut" value="保存">
				</div>
			</div>
	</div>
</div>
</body>
<script type="text/javascript">
$("#submitbut").click(function(){
	
	$("#submitbut").attr("disabled",true);
	var name = $("#name").val();
	var content = $("#content").val();
	var en_name = $("#en_name").val();
	var en_content = $("#en_content").val();
	var type = $("#type").val();
	var type2 = $("#type2").val();

	 $.post("/save/0",{"name":name,"en_name":en_name,"content":content,"en_content":en_content,"type":type,"type2":type2},function(result){
		 
		 	window.location="/edit?a_id="+result;
		    
		  });
});

$("#type").change(function(){ 
	$("#type2").html('<option value="0" >选择二级分类</option>');
	 var type_id =this.value;
	       


	 $.post("/changetype",{"type_id":type_id},function(res){
		 var dataObj=eval("("+res+")");

		 $.each(dataObj,function(idx,item){
				
			 //html+="<option value='"+item.type_id+"'>"+item.type_name+"</option>";
			 $("#type2").append("<option value='"+item.type_id+"'>"+item.type_name+"</option>");
			 });

	  });
	       
	 });
</script>
</html>